# try:
#     num = int(input('输入一个数字'))
# except Exception as e:
#     print(f'输入的是非数字{e}')
# else:
#     if num % 2 == 0:
#         print('偶数')
#     else:
#         print('奇数')
# info = input('请输入字符串')
# if info.isdigit():
#     # 判断是否为数字构成
#     with open("a.txt",mode="w",encoding="utf_8") as f:
#         f.write(info)
# else:
#     print('输入的内容有误')


# with open("./text1/b.txt",mode="r",encoding="utf_8") as f:
#     info = f.read()
#     print(info)
#     info1 = info.split(',')
#     print(info1)
#     for i in info1:
#         print(i)
# import json
# num = {'name':'小明','age':18,'sex':'男','hobby':['听歌','游戏','购物','吃饭','睡觉','打豆豆']}
# with open("data/data.json",mode="w",encoding="utf_8") as f:
#     json.dump(num,f,ensure_ascii=False)

import json
num = {"name":"小明","age":18,"sex":"男","hobby":["听歌","游戏","购物","吃饭","睡觉","打豆豆"],"address":{"country": "中国", "city": "北京", "street": "王府街" }}
with open("data/data.json",encoding="utf_8") as f:
    # json.dump(num,f,ensure_ascii=False)
    info = json.load(f)
    print(info)
print(info.get('name'))
print(info.get('hobby'))
print(info.get('address').get('country'))
